<?php
/**
* Implements requests with html output.
*<p>This is a derivation of the <i>CoreRequest</i> class that implements a request with an html-formatted
*string as output. Use this when you need to generate some html code without further processing by the
*client side.</p>
*<p>When invoked properly (see HtmlRequest on the client side), this request output will be inserted inside
*the calling DOM node on the client browser. Automatically.</p>
*<p>The resulting html code is augmented by any required <<script>> to include javascript calls or script
* inclusions.</p>
*<p>If an error is raised (via CoreRequest::SetError()) then it will be html-formatted and returned instead
* of the normal output.</p>
*@package Core
*@subpackage Request
*@author Willy Gardiol <willy@gardiol.org>
*@version 1.0
*/
abstract class CoreRequestHtml extends CoreRequest
{
	private $html;
	private $template = false;

	public function __construct( $template, $auth )
	{
		parent::__construct( $auth );
		$this->template = $template;
	}
	/**
	* Core processing, entry point.
	*<p>The abstract Process() method will be called to do the processing and create the HTML return string.</p>
	*/
	final public function DoRequest()
	{
		header("Content-type: text/html");

		$data = $this->CollectData();

		$output = new HtmlTemplate( $this->template, $data,true );
		$output->DrawHtml();
		if ( $this->GetError() )
			echo "<div class='output_error'><pre>".$this->GetError()."</pre></div>";
	}
	/** 
	* This will do the actual processing.
	*@return mixed The HTMl code (either string or HtmlTag class)
	*/
	abstract protected function CollectData();
}
?>